package com.igor.reporting.dao.problem;

import java.util.List;

import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Session;

import com.igor.reporting.entities.problem.Problem;

public class ProblemDAOImpl implements ProblemDAO {

	@Inject
	private Session session;

	public void add(Problem p) {
		if (p != null) {
			session.save(p);
		}
	}

	public void delete(Problem p) {
		if (p != null) {
			session.delete(p);
		}
	}

	public void update(Problem p) {
		if (p != null) {
			session.update(p);
		}
	}

	public Problem find(Long id) {
		return (Problem) session.load(Problem.class, id);
	}

	public List<Problem> findAll() {
		return session.createCriteria(Problem.class).list();
	}

}
